<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../css/bootstrap.min.css">
</head>
<body>
<form class="form-inline">
    <div class="form-group">
        <label for="exampleInputName2">商品名称：</label>
        <input type="text" name="shoegood" class="form-control" id="shoegood" placeholder="商品名">

    </div>
    <div class="form-group">
        <label for="exampleInputEmail2">品牌：</label>
        <select name="brand" id="brand" class="form-control">
            <option value="耐克（NIKE）">耐克（NIKE）</option>
            <option value="阿迪达斯（adidas）">阿迪达斯（adidas）</option>
            <option value="蓝中鸟（LanZhongNiao）">蓝中鸟（LanZhongNiao）</option>
            <option value="特步（XTEP）">特步（XTEP）</option>
            <option value="热风（Hotwind）">热风（Hotwind）</option>
            <option value="威世米邦（WEISHIMIBANG）">威世米邦（WEISHIMIBANG）</option>
            <option value="骆驼（CAMEL）">骆驼（CAMEL）</option>
        </select>
    </div>
    <div class="form-group">
        <label for="exampleInputEmail2">日期：</label>
        <select name="days" id="days" class="form-control">
            <option value="3">三天内</option>
            <option value="7">一星期内</option>
            <option value="30">一个月内</option>
            <option value="365">一年内</option>
        </select>
    </div>
    <input type="button" class="btn btn-default" onclick="f()" value="查询"></input>
</form>
<div>
    <div class="table-responsive">
        <table class="table" id="aa">
            <tr >
                <td class="active" style="width: 25%">商品名</td>
                <td class="active" style="width: 10%">图片</td>
                <td class="active" style="width: 10%">品牌</td>
                <td class="active" style="width: 10%">价格</td>
                <td class="active" style="width: 10%">上架时间</td>
                <td class="active" style="width: 10%">状态</td>

            </tr>

        </table>



    </div>
</div>

<script src="../js/jquery-3.3.1.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/cookie.js"></script>
<script>

   /* var  a = window.parent.document.getElementsByName("shoegood").val;
    var  b = window.parent.document.getElementsByName("brand").val;
    var  c = window.parent.document.getElementsByName("days").val;*/
   function f() {
       var  a = document.getElementById('shoegood').value
       var  b = document.getElementById('brand').value;
       var  c = document.getElementById('days').value;

       GetChildValue(a,b,c);
   }
    function GetChildValue(a,b,c) {
        $.getJSON("http://localhost:8080/nb/time?age=" + c + "&brand=" + b + "&goodName=" + a, function (data) {

            console.log(a,b,c)
            var html = ''
            for (let i = 0; i < data.length; i++) {
                html += `
            <tr style="text-align: center">
            <td class="active" style="width: 10%"><img src="${data[i].goodPhoto}" alt=""></td>
                <td class="active" style="width: 25%">${data[i].goodName}</td>

                <td class="active" style="width: 10%">${data[i].goodBrand}</td>
                <td class="active" style="width: 10%">${data[i].goodMoney}</td>
                <td class="active" style="width: 10%">${data[i].goodDate}</td>
                `
                    if(data[i].reserve1 == "已下架"){
                        html +=`
                         <td class="active" style="width: 10%">${data[i].reserve1}</td>
                         </tr>
                        `
                        $("#aa").html(html)
                    }else {
                        html +=`
                         <td class="active" style="width: 10%"><a href="" onclick="xiajia(${data[i].goodId})">下架商品</a></td>
                          </tr>
                        `
                        $("#aa").html(html)
                    }
            }



        })
    }

    function xiajia(j) {
        $.getJSON("http://localhost:8080/nb/xiuupdate?id=" + j,function (data) {
            alert(data)

        })
    }
</script>
</body>
</html>